home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / vidhrdw / shootout.c < prev    next >
C/C++ Source or Header  |  2000-03-07  |  5KB  |  185 lines

  1. /*
  2.     Video Hardware for Shoot Out
  3.     prom GB09.K6 may be related to background tile-sprite priority
  4. */
  5.  
  6. #include "driver.h"
  7. #include "vidhrdw/generic.h"
  8.  
  9. #define NUM_SPRITES 128
  10.  
  11. extern unsigned char *shootout_textram;
  12. static struct sprite_list *sprite_list;
  13.  
  14.  
  15. int shootout_vh_start( void ){
  16.     if( generic_vh_start()==0 ){
  17.         sprite_list = sprite_list_create( NUM_SPRITES, SPRITE_LIST_BACK_TO_FRONT );
  18.         if( sprite_list ){
  19.             int i;
  20.             sprite_list->sprite_type = SPRITE_TYPE_STACK;
  21.  
  22.             for( i=0; i<NUM_SPRITES; i++ ){
  23.                 struct sprite *sprite = &sprite_list->sprite[i];
  24.                 sprite->pal_data = Machine->gfx[1]->colortable;
  25.                 sprite->tile_width = 16;
  26.                 sprite->tile_height = 16;
  27.                 sprite->total_width = 16;
  28.                 sprite->line_offset = 16;
  29.             }
  30.             sprite_list->max_priority = 1;
  31.  
  32.             return 0;
  33.         }
  34.         generic_vh_stop();
  35.     }
  36.     return 1; /* error */
  37. }
  38.  
  39. static void get_sprite_info( void ){
  40.     const struct GfxElement *gfx = Machine->gfx[1];
  41.     const UINT8 *source = spriteram;
  42.     struct sprite *sprite = sprite_list->sprite;
  43.     int count = NUM_SPRITES;
  44.  
  45.     int attributes, flags, number;
  46.  
  47.     while( count-- ){
  48.         flags = 0;
  49.         attributes = source[1];
  50.         /*
  51.             76543210
  52.             xxx            bank
  53.                x        vertical size
  54.                 x        priority
  55.                  x        horizontal flip
  56.                   x        flicker
  57.                    x    enable
  58.         */
  59.         if ( attributes & 0x01 ){ /* enabled */
  60.             flags |= SPRITE_VISIBLE;
  61.             sprite->priority = (attributes&0x08)?1:0;
  62.             sprite->x = (240 - source[2])&0xff;
  63.             sprite->y = (240 - source[0])&0xff;
  64.  
  65.             number = source[3] + ((attributes&0xe0)<<3);
  66.             if( attributes & 0x04 ) flags |= SPRITE_FLIPX;
  67.             if( attributes & 0x02 ) flags |= SPRITE_FLICKER; /* ? */
  68.  
  69.             if( attributes & 0x10 ){ /* double height */
  70.                 number = number&(~1);
  71.                 sprite->y -= 16;
  72.                 sprite->total_height = 32;
  73.             }
  74.             else {
  75.                 sprite->total_height = 16;
  76.             }
  77.             sprite->pen_data = gfx->gfxdata + number * gfx->char_modulo;
  78.         }
  79.         sprite->flags = flags;
  80.         sprite++;
  81.         source += 4;
  82.     }
  83. }
  84.  
  85. static void get_sprite_info2( void ){
  86.     const struct GfxElement *gfx = Machine->gfx[1];
  87.     const UINT8 *source = spriteram;
  88.     struct sprite *sprite = sprite_list->sprite;
  89.     int count = NUM_SPRITES;
  90.  
  91.     int attributes, flags, number;
  92.  
  93.     while( count-- ){
  94.         flags = 0;
  95.         attributes = source[1];
  96.         if ( attributes & 0x01 ){ /* enabled */
  97.             flags |= SPRITE_VISIBLE;
  98.             sprite->priority = (attributes&0x08)?1:0;
  99.             sprite->x = (240 - source[2])&0xff;
  100.             sprite->y = (240 - source[0])&0xff;
  101.  
  102.             number = source[3] + ((attributes&0xc0)<<2);
  103.             if( attributes & 0x04 ) flags |= SPRITE_FLIPX;
  104.             if( attributes & 0x02 ) flags |= SPRITE_FLICKER; /* ? */
  105.  
  106.             if( attributes & 0x10 ){ /* double height */
  107.                 number = number&(~1);
  108.                 sprite->y -= 16;
  109.                 sprite->total_height = 32;
  110.             }
  111.             else {
  112.                 sprite->total_height = 16;
  113.             }
  114.             sprite->pen_data = gfx->gfxdata + number * gfx->char_modulo;
  115.         }
  116.         sprite->flags = flags;
  117.         sprite++;
  118.         source += 4;
  119.     }
  120. }
  121.  
  122. static void draw_background( struct osd_bitmap *bitmap ){
  123.     const struct rectangle *clip = &Machine->drv->visible_area;
  124.     int offs;
  125.     for( offs=0; offs<videoram_size; offs++ ){
  126.         if( dirtybuffer[offs] ){
  127.             int sx = (offs%32)*8;
  128.             int sy = (offs/32)*8;
  129.             int attributes = colorram[offs]; /* CCCC -TTT */
  130.             int tile_number = videoram[offs] + 256*(attributes&7);
  131.             int color = attributes>>4;
  132.  
  133.             drawgfx(tmpbitmap,Machine->gfx[2],
  134.                     tile_number&0x7ff,
  135.                     color,
  136.                     0,0,
  137.                     sx,sy,
  138.                     clip,TRANSPARENCY_NONE,0);
  139.  
  140.             dirtybuffer[offs] = 0;
  141.         }
  142.     }
  143.     copybitmap(bitmap,tmpbitmap,0,0,0,0,&Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  144. }
  145.  
  146. static void draw_foreground( struct osd_bitmap *bitmap ){
  147.     const struct rectangle *clip = &Machine->drv->visible_area;
  148.     const struct GfxElement *gfx = Machine->gfx[0];
  149.     int sx,sy;
  150.  
  151.     unsigned char *source = shootout_textram;
  152.  
  153.     for( sy=0; sy<256; sy+=8 ){
  154.         for( sx=0; sx<256; sx+=8 ){
  155.             int attributes = *(source+videoram_size); /* CCCC --TT */
  156.             int tile_number = 256*(attributes&0x3) + *source++;
  157.             int color = attributes>>4;
  158.             drawgfx(bitmap,gfx,
  159.                 tile_number, /* 0..1024 */
  160.                 color,
  161.                 0,0,
  162.                 sx,sy,
  163.                 clip,TRANSPARENCY_PEN,0);
  164.         }
  165.     }
  166. }
  167.  
  168. void shootout_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh){
  169.     get_sprite_info();
  170.     sprite_update();
  171.     draw_background( bitmap );
  172.     sprite_draw( sprite_list, 1);
  173.     draw_foreground( bitmap );
  174.     sprite_draw( sprite_list, 0);
  175. }
  176.  
  177. void shootouj_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh){
  178.     get_sprite_info2();
  179.     sprite_update();
  180.     draw_background( bitmap );
  181.     sprite_draw( sprite_list, 1);
  182.     draw_foreground( bitmap );
  183.     sprite_draw( sprite_list, 0);
  184. }
  185.